Review checks for Error string when checking that bad arguments are handled
authoremellor@leeni.uk.xensource.com <emellor@leeni.uk.xensource.com>
Wed, 16 Nov 2005 11:36:47 +0000 (12:36 +0100)
committeremellor@leeni.uk.xensource.com <emellor@leeni.uk.xensource.com>
Wed, 16 Nov 2005 11:36:47 +0000 (12:36 +0100)
correctly.  Many checks were looking using output.find("Error") > 1, which is
incorrect, as we do not guarantee that the word "Error" will be first in the
output (never mind the fact that strings are indexed from 0).

All these checks have been changed to compare against -1.  In particular, this
should fix the failure of create_noparm_neg and create_badparm_neg on a machine
with the /etc/xen/xmdefconfig file in place, as xm create issues the
Using config file "/etc/xen/xmdefconfig" diagnostic before reporting the error.

Signed-off-by: Ewan Mellor <ewan@xensource.com>
31 files changed:
tools/xm-test/tests/block-create/06_block_attach_baddomain_neg.py
tools/xm-test/tests/block-create/07_block_attach_baddevice_neg.py
tools/xm-test/tests/block-create/08_block_attach_bad_filedevice_neg.py
tools/xm-test/tests/console/01_console_badopt_neg.py
tools/xm-test/tests/console/02_console_baddom_neg.py
tools/xm-test/tests/create/02_create_noparm_neg.py
tools/xm-test/tests/create/03_create_badparm_neg.py
tools/xm-test/tests/create/05_create_noroot_noram_neg.py
tools/xm-test/tests/destroy/02_destroy_noparm_neg.py
tools/xm-test/tests/destroy/03_destroy_nonexist_neg.py
tools/xm-test/tests/destroy/04_destroy_badparm_neg.py
tools/xm-test/tests/dmesg/02_dmesg_basic_neg.py
tools/xm-test/tests/help/01_help_basic_pos.py
tools/xm-test/tests/help/02_help_basic_neg.py
tools/xm-test/tests/help/03_help_badparm_neg.py
tools/xm-test/tests/help/05_help_nonroot_pos.py
tools/xm-test/tests/list/02_list_badparm_neg.py
tools/xm-test/tests/list/03_list_nonexist_neg.py
tools/xm-test/tests/list/06_list_nonroot.py
tools/xm-test/tests/memset/02_memset_badparm_neg.py
tools/xm-test/tests/pause/02_pause_badopt_neg.py
tools/xm-test/tests/pause/03_pause_badname_neg.py
tools/xm-test/tests/pause/04_pause_badid_neg.py
tools/xm-test/tests/reboot/02_reboot_badopt_neg.py
tools/xm-test/tests/reboot/03_reboot_badname_neg.py
tools/xm-test/tests/restore/02_restore_badparm_neg.py
tools/xm-test/tests/restore/03_restore_badfilename_neg.py
tools/xm-test/tests/save/02_save_badparm_neg.py
tools/xm-test/tests/save/03_save_bogusfile_neg.py
tools/xm-test/tests/shutdown/02_shutdown_badparm_neg.py
tools/xm-test/tests/shutdown/03_shutdown_nonexist_neg.py

index cc6746d47d3722bac12377835580c4f83ee53e7a..856b7c0f57071a67edf11c9ccf7944b08dfbdd47 100644 (file)
@@ -11,7 +11,7 @@ eyecatcher = "Error"
 where = output.find(eyecatcher)
 if status == 0:
        FAIL("xm block-attach returned bad status, expected non 0, status is: %i" % status )
-elif where 1:
+elif where == -1:
        FAIL("xm block-attach returned bad output, expected Error, output is: %s" % output )
        
 
index 930b9c13007278a36bdf28701a76c75fbc8aa14a..0d388a5baced0be78d6d4c7dae124c2e24531eeb 100644 (file)
@@ -42,7 +42,7 @@ eyecatcher = "Error"
 where = output.find(eyecatcher)
 if status == 0:
        FAIL("xm block-attach returned bad status, expected non 0, status is: %i" % status )
-elif where 1:
+elif where == -1:
        FAIL("xm block-attach returned bad output, expected Error, output is: %s" % output )
 
 try:
index 50073037be8792718ce03a394d21e2812d41ef02..2420fec3ba2d2d153d4daa590a3f91d3d3747ba2 100644 (file)
@@ -41,7 +41,7 @@ eyecatcher = "Error"
 where = output.find(eyecatcher)
 if status == 0:
        FAIL("xm block-attach returned bad status, expected non 0, status is: %i" % status )
-elif where 1:
+elif where == -1:
        FAIL("xm block-attach returned bad output, expected Error, output is: %s" % output )
        
 try:
index 0fa8f8384ed9231c40a89b4e13ea6bf24f2c9a21..1c00afef4f46a39d27d2a0aaf8596b40b2da87b3 100644 (file)
@@ -17,5 +17,5 @@ eyecatcher = "Error"
 where = output.find(eyecatcher)
 if status == 0:
     FAIL("xm console returned invalid %i != 0" % status)
-elif where 1:
+elif where == -1:
     FAIL("xm console didn't report error on bad argument")
index 217dadfc13904a819b1663f76f98525f18cac314..56bf1a045134a1eefae22bf3b23b865acd94e460 100644 (file)
@@ -15,7 +15,7 @@ eyecatcher = "Error"
 where = output.find(eyecatcher)
 if status == 0:
     FAIL("xm console returned invalid %i != 0" % status)
-elif where 1:
+elif where == -1:
     FAIL("xm console failed to report error on bad domid")
 
 status, output = traceCommand("xm console NON_EXIST")
@@ -23,5 +23,5 @@ eyecatcher = "Error"
 where = output.find(eyecatcher)
 if status == 0:
     FAIL("xm console returned invalid %i != 0" % status)
-elif where 1:
+elif where == -1:
     FAIL("xm console failed to report error on bad domname") 
index 7d6a85a5fb5107745288bd7510f73ac19282dffb..54f882853c0642b0afd826bf90a11ea8bb1f94c2 100644 (file)
@@ -12,6 +12,6 @@ eyecatcher = "Error:"
 where = output.find(eyecatcher)
 if status == 0:
     FAIL("xm create returned invalid %i != 0" % status)
-elif where 1:
+elif where == -1:
     FAIL("xm create failed to report error on missing args")
 
index 68cfeb6eb9e566205f5f6665228183d39e4ca3b1..2a64cf3305666fed0aa9b3521286afc180132759 100644 (file)
@@ -15,5 +15,5 @@ from XmTestLib import *
 status, output = traceCommand("xm create -x")
 eyecatcher = "Error:"
 where = output.find(eyecatcher)
-if where != 0:
+if where == -1:
     FAIL("xm create failed to report error on bad arg")
index 8e92a5412c6fc9e77c305bda9187ba88cd982382..b6756c633d1fe5b7040ab1442a091a92ea373492 100644 (file)
@@ -22,5 +22,5 @@ time.sleep(15)
 eyecatcher = "NOROOT"
 status, output = traceCommand("xm list")
 where = output.find(eyecatcher)
-if where != -1 :
+if where != -1:
        FAIL("xm create test05 passed with no root and no ramdisk. Expected result: Fail.")
index 3a634053c502e69fe40b41f3c9f52f69d363b9d1..8fadb1ecedebb98e0215c4f609d5a276167f360a 100644 (file)
@@ -12,5 +12,5 @@ eyecatcher = "Error:"
 where = output.find(eyecatcher)
 if status == 0:
     FAIL("xm destroy returned invalid %i != 0" % status)
-elif where 1:
+elif where == -1:
     FAIL("xm destroy failed to report error for missing arg")
index 0c77347f3d304af909aa68584fe2b9e513e9e97f..9520a65e2bf67175fb090d5deccedee78423f85e 100644 (file)
@@ -12,5 +12,5 @@ eyecatcher = "Error:"
 where = output.find(eyecatcher)
 if status == 0:
     FAIL("xm destroy returned invalid %i != 0" % status)
-elif where 1:
+elif where == -1:
     FAIL("xm destroy failed to report error for bad arg")
index 5814195c0d3a2ca93d0a7eb2bc5c2f51a2339314..179b4d0c364917abae3f7b7498b6801fa73d47ba 100644 (file)
@@ -12,5 +12,5 @@ eyecatcher = "Error:"
 where = output.find(eyecatcher)
 if status == 0:
     FAIL("xm destroy returned invalid %i != 0" % status)
-elif where 1:
+elif where == -1:
     FAIL("xm destroy failed to report error for bad domid")
index 10cd7a7cfd682ef1ee5a8a308d7d0ac67fb78a54..e074c0d16aaeb729c261128f74771fde17a8d1d6 100644 (file)
@@ -12,6 +12,6 @@ eyecatcher = "Error:"
 where = output.find(eyecatcher)
 if status == 0:
     FAIL("xm dmesg returned invalid %i != 0" % status)
-elif where == 1:
+elif where == -1:
     FAIL("xm dmesg failed to report error for bad arg")
 
index b7162a5f52893670817efbc30f349f068b8bc7cb..11b84f06b7dd96f40d279bfa9ed55e2d7b2f86d9 100644 (file)
@@ -10,5 +10,5 @@ from XmTestLib import *
 status, output = traceCommand("xm help")
 eyecatcher = "Usage:"
 where = output.find(eyecatcher)
-if where != 0:
+if where == -1:
     FAIL("xm help: didn't see the usage string")
index 28b2a07a108af09c6e7288a4a22d0fa5cfdba0d1..09116ab2c0be9619e52e1b34ef69931d7090b0bf 100644 (file)
@@ -10,5 +10,5 @@ from XmTestLib import *
 status, output = traceCommand("xm")
 eyecatcher = "Usage:"
 where = output.find(eyecatcher)
-if where != 0:
+if where == -1:
     FAIL("xm: didn't display usage when given no arguments")
index 1c9cd62606562e1429321f70e8e52c20a5710727..1064a755a331897bbe590623c4da208be81e824b 100644 (file)
@@ -10,5 +10,5 @@ from XmTestLib import *
 status, output = traceCommand("xm -x")
 eyecatcher = "Error:"
 where = output.find(eyecatcher)
-if where != 0:
+if where == -1:
     FAIL("xm failed to report error for bad arg")
index 9798735c1ee75537a6eab82ec924a3fe3ec7e634..87a395f62f316b10c40583f982a9d6e181ea837a 100644 (file)
@@ -13,5 +13,5 @@ becomeNonRoot()
 status, output = traceCommand("xm help")
 eyecatcher = "Usage:"
 where = output.find(eyecatcher)
-if where != 0:
+if where == -1:
     FAIL("xm help: didn't see the usage string")
index f018e5c20e850e75d4694b4381298c21719f14d9..5c40694b932c9a44722baebb45066655ff9238b8 100644 (file)
@@ -12,5 +12,5 @@ eyecatcher = "Error:"
 where = output.find(eyecatcher)
 if status == 0:
     FAIL("xm list returned invalud %i != 0" % status)
-elif where 1:
+elif where == -1:
     FAIL("xm list failed to report error for bad arg")
index db3175fb871bcb7a512ce5c1f7ec37482b237a44..04acbd6b9caa403ebca400d01d924c1eaff21b6e 100644 (file)
@@ -12,6 +12,6 @@ eyecatcher = "Error:"
 where = output.find(eyecatcher)
 if status == 0:
     FAIL("xm list returned invalid %i != 0" % status)
-elif where 1:
+elif where == -1:
     FAIL("xm list failed to report error for invalid domid")
 
index 7b61508cb76e3db0eebd0262b02b57b13757fc86..c10ac56da8eda00af426a66e37b493d8f65ab097 100644 (file)
@@ -11,5 +11,5 @@ becomeNonRoot()
 status, output = traceCommand("xm list")
 eyecatcher = "Error: Most commands need root access"
 where = output.find(eyecatcher)
-if where != 0:
+if where == -1:
     FAIL("xm help: didn't see the root hint, saw %s" % output)
index f2b9e788e08e9768af07bc64514d8118b8f65463..07f7e2c635f632aba12ae744c7caf5e5732a696e 100644 (file)
@@ -24,7 +24,7 @@ eyecatcher = "Error:"
 where = output.find(eyecatcher)
 if status == 0:
     FAIL("xm mem-set returned invalid %i == 0" % status)
-elif where 1:
+elif where == -1:
     FAIL("xm mem-set failed to report error for missing arg")
 
 # destroy non existent parm input - negative test
@@ -32,7 +32,7 @@ status, output = traceCommand("xm mem-set -x")
 where = output.find(eyecatcher)
 if status == 0:
     FAIL("xm mem-set returned invalid %i == 0" % status)
-elif where != 0:
+elif where == -1:
     FAIL("xm mem-set failed to report error for bad arg")
 
 # destroy non existent domain - negative test
@@ -40,14 +40,14 @@ status, output = traceCommand("xm mem-set 6666")
 where = output.find(eyecatcher)
 if status == 0:
     FAIL("xm mem-set returned invalid %i == 0" % status)
-elif where != 0:
+elif where == -1:
     FAIL("xm mem-set failed to report error for invalid domid")
 
 # destroy non existent domain and memory - negative test
 status, output = traceCommand("xm mem-set 6666 64")
 where = output.find(eyecatcher)
 if status == 0:
-    FAIL("xm mem-set returned invalid %i != 0" % status)
-elif where != 0:
+    FAIL("xm mem-set returned invalid %i == -1" % status)
+elif where == -1:
     FAIL("xm mem-set failed to report error for invalid domid")
 
index 4d504d1d92edc62ad428b2350206e61104e393ef..18eda676411cbe0a3420c66b13cea22fdd356dde 100644 (file)
@@ -25,7 +25,7 @@ where = output.find(eyecatcher)
 if status == 0:
     domain.destroy()
     FAIL("xm pause returned bad status, expected non 0, status is: %i" % status )
-elif where 1:
+elif where == -1:
     domain.destroy()
     FAIL("xm pause returned bad output, expected Error, output is: %s" % output )
 
index 7ec1bc4109f132adea0b09412aa0598f506218ba..982034c66beb5e764714e3aac9ec209020dd4e44 100644 (file)
@@ -14,5 +14,5 @@ eyecatcher = "Error"
 where = output.find(eyecatcher)
 if status == 0:
     FAIL("xm pause returned bad status, expected non 0, status is: %i" % status )
-elif where 1:
+elif where == -1:
     FAIL("xm pause returned bad output, expected Error, output is: %s" % output )
index c5bd5785009a0d67009f1980189c4a62e45b8c9a..ffd1be2168742cad3be75e8f308d775c8455c1ce 100644 (file)
@@ -14,5 +14,5 @@ eyecatcher = "Error"
 where = output.find(eyecatcher)
 if status == 0:
     FAIL("xm pause returned bad status, expected non 0, status is: %i" % status )
-elif where 1:
+elif where == -1:
     FAIL("xm pause returned bad output, expected Error, output is: %s" % output )
index cfcd52c021a207283b56f7cd472fbae6dcc392cc..b0a23bb4a5d03880345402ab73c4206827be362b 100644 (file)
@@ -25,7 +25,7 @@ where = output.find(eyecatcher)
 if status == 0:
     domain.destroy()
     FAIL("xm reboot returned invalid %i == 0" % status )
-elif where 1:
+elif where == -1:
     domain.destroy()
     FAIL("xm reboot failed to report error for bad arg")
 
index aa1aabb6e0439658be3e1d4cca4dd20160de5ba8..480e5dd39840ce4341665ccba129b3dffd85e09b 100644 (file)
@@ -14,5 +14,5 @@ eyecatcher = "Error"
 where = output.find(eyecatcher)
 if status == 0:
     FAIL("xm reboot returned invalid %i == 0" % status )
-elif where 1:
+elif where == -1:
     FAIL("xm reboot failed to report error for non-existent domain" )
index 6f1a5da07903ee29fe8b25f2341db3e894a398d8..aee5b5da7212dcd19b950419b727433b55a23846 100644 (file)
@@ -21,5 +21,5 @@ if status == 0:
     FAIL("xm restore returned bad status, expected non 0, status is: %i" % status)
 elif where2 == 0:
     FAIL("xm restore returned a stack dump, expected nice error message") 
-elif where1 > 0:
+elif where1 == -1:
     FAIL("xm restore returned bad output, expected Error:, output is: %s" % output)
index 9a35cc3ae1d87102663a7ec11cb806c0bee237b0..7639c4b90e05f4a579aac5a1cc9ae341503fc751 100644 (file)
@@ -21,5 +21,5 @@ if status == 0:
     FAIL("xm restore returned bad status, expected non 0, status is: %i" % status)
 elif where2 == 0:
     FAIL("xm restore returned a stack dump, expected nice error message") 
-elif where1 > 0:
+elif where1 == -1:
     FAIL("xm restore returned bad output, expected Error:, output is: %s" % output)
index 5d81c75183384dc1f6135a2fc5134ebed6412fe8..7966ff1ee15cedbe224a97cf4f302c2cd7225d04 100644 (file)
@@ -21,5 +21,5 @@ if status == 0:
     FAIL("xm save returned bad status, expected non 0, status is: %i" % status)
 elif where2 == 0:
     FAIL("xm save returned a stack dump, expected nice error message") 
-elif where1 > 0:
+elif where1 == -1:
     FAIL("xm save returned bad output, expected Error:, output is: %s" % output)
index 4f1d042f42b83170a05132e53d1b9750d47c1727..de66e6080f56224db5dd8f8a5af7ee92db74b9ca 100644 (file)
@@ -38,5 +38,5 @@ if status == 0:
     FAIL("xm save returned bad status, expected non 0, status is: %i" % status)
 elif where1 == 0:
     FAIL("xm save returned a stack dump, expected nice error message")
-elif where2 > 0:
+elif where2 == -1:
     FAIL("xm save returned bad output, expected Error:, output is: %s" % output)
index 34e5c23d3fee5ef5412aa058b6e2430f21429994..8ec2a5b3c299cc08cc06eb24a358d001b752cd84 100644 (file)
@@ -32,7 +32,7 @@ ret, output = traceCommand("xm shutdown -x %s" % domain.getName())
 where = output.find(eyecatcher)
 if (ret == 0):
     FAIL("xm shutdown returned invalid %i == 0" % ret)
-elif where != 0:
+elif where == -1:
     FAIL("xm shutdown failed to report error for bad arg")
 
 # Stop the domain (nice shutdown)
index 160ecdcdc219640e5acb65c6f0a7be1fef08d0e4..4998911d887462ab8f6c2702f7f927b9e1d2857e 100644 (file)
@@ -18,5 +18,5 @@ ret, output = traceCommand("xm shutdown 9999")
 where = output.find(eyecatcher)
 if (ret == 0):
     FAIL("xm shutdown returned invalid %i == 0" % ret)
-elif where != 0:
+elif where == -1:
     FAIL("xm shutdown failed to report error for bad domid")